package com.ldq.imooc.basics.multiThread;

/**
 * @author : 李道泉
 * @description :
 * @date : 2018/4/23 21:08
 * @modified by :
 */
public class Stage extends Thread {

    @Override
    public void run() {

        System.out.println("日寇山本特工队偷袭386旅独立团团部逃至平安县城。");

        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("李云龙：娘的，我早就料到他会逃到平安城。传我命令：全团迅速规建，准备攻打平安城！");

        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println("李云龙独立团及配合武装上万人攻城，山本逐渐支撑不住，准备拿李云龙新婚夫人秀芹作挡箭牌。");

        ArmyRunnable army386 = new ArmyRunnable();
        ArmyRunnable armyRi = new ArmyRunnable();

        //使用Runnable接口创建线程
        Thread armOfLiYunlong = new Thread(army386, "李云龙独立团");
        Thread armOfShanBen = new Thread(armyRi, "山本特工队");

        //启动线程
        armOfShanBen.start();
        armOfLiYunlong.start();

        //舞台线程休眠
        try {
            Thread.sleep(50);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println("楼下的八路们，这个女人你们认识么？");

        Thread riKou = new KeyPersonThread();
        riKou.setName("山本一木");

        System.out.println("山本一木：李云龙阁下，我建议我们双方挺火十五分钟！");

        //军队停止作战
        army386.keepRun = false;
        armyRi.keepRun = false;

        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        riKou.start();
        try {
            riKou.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println("山本一木被李云龙的炮弹炸死，小日本灰飞烟灭，攻陷平安城！");
        System.out.println("晋西北日寇据点均被友军联合拔除。");
    }

    public static void main(String[] args) {

        new Stage().start();
    }
}
